package part1.language_basis.day03;

//运算符的演示
public class OperDemo {
    public static void main(String[] args) {
        /*
        1. 运算符：
        - 算术：+，-，*，/，%，++，--
        - 关系：>、<、>=、<=、==、!=
        - 逻辑：&&、||、!
        - 赋值：=、+=、-=、*=、/=、%=
        - 字符串连接：+
        - 条件：boolean？数1：数2

         */

        //找两个数中的最大值
        int a = 5, b = 6;
        int max = a > b ? a : b;
        System.out.println(max);


        //4小面试题：
        /*
        short s = 5;
        //s = s +20; //编译错误 需强转 改为s=(short)(s+10);
        s+=20; //相当于s=(short)(s+10);
        int a = 5;
        a+=10; //相当于a=(int)(a+10);
        System.out.println(a); //15
        a*=2;
        System.out.println(a); //30
        a/=6;
        System.out.println(a); //5

         */




        /*
         * 逻辑运算符  && || ！
         * 1)&&：短路与(并且) 两边都为真则为真 见false则false
         * */
        /*
        int a=5,b=10,c=5;
        boolean b1 = a>b && c++>2;
        System.out.println(b1);
        System.out.println(c);   //5发生短路了

         */

        /*
        int a = 5, b = 10, c = 5;
        boolean b1 = b>=a && b<c;
        System.out.println(b1);
        System.out.println(b<=c && b>a);
        System.out.println(a==b && b<a);
        System.out.println(b!=c && b>a);

        int age = 99;
        System.out.println(age>=18 && age<=50); //年龄在18到50之间
        int score = 86;
        System.out.println(score>=0 && score<=100); //成绩在0到100之间

         */
        /*
        int a=5,b=10,c=5;
        System.out.println(b>=a || b<c);
        System.out.println(b<=c || b>a);
        System.out.println(b!=c || b>a);
        System.out.println(a==b || b<a);
        int score = 90;
        System.out.println(score<0 || score>100); //成绩不合法验证

        boolean b2 = !(a<b);
        System.out.println(b2);     //!true = false
        System.out.println(!(a>b)); //!false = true

         */


        //运算符
        //a++，++a
        // 单独使用在前在后都一样
        // 被使用时，在前在后不一样
        //          a++的值为a   ++a的值为a+1
        /*
        int a =5,b=5;
        int c = a++; //将a++的值5赋值给c  同时a自增1
        int d = ++b; //将++b的值6赋值给d  同时b自增1
        System.out.println(a); //6
        System.out.println(b); //6
        System.out.println(c); //5
        System.out.println(d); //6

        int a1=5,b1=5;
        System.out.println(a1++); //5
        System.out.println(a1);    //6
        System.out.println(++b1); //6
        System.out.println(b1);   //6

         */
        /*
        int a=7,b=8;
        a++;
        ++b;
        int c = --a;
        int d = b++;
        int e = d--;
        int f = --b;
        System.out.println(a);//7
        System.out.println(b);//9
        System.out.println(c);//7
        System.out.println(d);//8
        System.out.println(e);//9
        System.out.println(f);//9

         */


        //关系运算符
        /*
        int a=5,b=6,c=5;
        boolean b1 = a>b;
        System.out.println(b1); //false
        System.out.println(c<b); //true
        System.out.println(a>=c); //true
        System.out.println(a<=b); //true
        System.out.println(a==c); //true
        System.out.println(a!=c); //false

        System.out.println(a%2==0); //false
        System.out.println(a+c>b);  //true
        System.out.println(a++>5);  //false ---a自增1变为6
        System.out.println(a++>5);  //true  ---a自增1变为7

         */


    }
}
